package com.hkp.controller;

import com.hkp.service.ResearchProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 统计报表控制器
 */
@Controller
@RequestMapping("/stat")
public class StatController {

    @Autowired
    private ResearchProjectService projectService;

    /**
     * 统计报表页面
     */
    @GetMapping("/report")
    public String report() {
        return "stat/report";
    }

    /**
     * 按学院统计项目数量API
     */
    @GetMapping("/api/stats/college")
    @ResponseBody
    public List<Map<String, Object>> collegeStats() {
        return projectService.getProjectCountByCollege();
    }

    /**
     * 按状态统计项目数量API
     */
    @GetMapping("/api/stats/status")
    @ResponseBody
    public List<Map<String, Object>> statusStats() {
        return projectService.getProjectCountByStatus();
    }
}